
package com.webbei.Backstage.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.webbei.Backstage.service.BackstateSer;
import com.webbei.Backstagepojo.CombineList;
import com.webbei.pojo.Customerlimit;
import com.webbei.pojo.Userhot;

public class ShowCustomerLimt extends ActionSupport{
     private List<Customerlimit> cuslimit;
     private List<Userhot> hotlist;
     private List<CombineList> comlist;
     
     private BackstateSer bao;
 	 private String page;
 	 private int pagenow =1;
 	 private int maxpage = 10;
 	 private int pagecount;
 	 private int total;
	 public String execute(){
	 comlist=new ArrayList<CombineList>();
		 if(page!=null){
	        	pagenow=Integer.parseInt(page);
	        }
	      total=bao.customerlimitCount();
	      System.out.println("total:"+total);
			  pagecount = (total% maxpage) == 0 ? (total/maxpage): (total/maxpage+ 1);
				if (pagenow> pagecount) {
					pagenow=pagecount;
				}
				if (pagenow< 1) {
					pagenow = 1;
				}
				int start = (pagenow - 1) * maxpage;
				  cuslimit= bao.cuslimitlist(start);
				 
				  System.out.println("cusm:"+cuslimit.size());
				  for(int i=0;i<cuslimit.size();i++){
					  Userhot u=new Userhot();
					  CombineList c=new CombineList();
					  c.setCancustom(cuslimit.get(i).getCanCustom());
					  c.setCancomment(cuslimit.get(i).getCanComment());
					  c.setCanreport(cuslimit.get(i).getCanReport());
					  c.setCanshare(cuslimit.get(i).getCanShare());	
					  String username = cuslimit.get(i).getUserName();
						  u=bao.uhot(username);	
					  if(u!=null){
						  c.setBereportedcount(u.getBereportedCount());
						  c.setReportcount(u.getReportfailCount());
						 
					  }
					  c.setUsername(username);
				      comlist.add(c);
				  }
    	  return SUCCESS;
      }
	
	public BackstateSer getBao() {
		return bao;
	}
	public void setBao(BackstateSer bao) {
		this.bao = bao;
	}
	


	public List<CombineList> getComlist() {
		return comlist;
	}

	public void setComlist(List<CombineList> comlist) {
		this.comlist = comlist;
	}

	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public int getPagenow() {
		return pagenow;
	}
	public void setPagenow(int pagenow) {
		this.pagenow = pagenow;
	}
	public int getPagecount() {
		return pagecount;
	}
	public void setPagecount(int pagecount) {
		this.pagecount = pagecount;
	}

	 
}
